
import React from "react";
import { hashHistory } from 'react-router';
import Util from "../../util/Util";

/*导出组件*/
export default class Role_item extends React.Component {
    constructor(props) {
        super(props)
        this.state={
            context:[]
        }
        this.name=[];
        this.context = [];
        this.pageNum;
        this.pageSize;
    }
    /*页面初始化*/
    componentWillMount() {
        this.context = this.props.item;
        this.pageNum = this.props.pageNum;
        this.pageSize = this.props.pageSize;
    }

    /*编辑角色*/
    edit(id){
        this.props.edit(id);
    }

    /*删除角色*/
    deletz(id){
        this.props.deletz(id);
    }

    /*可编辑按钮展示*/
    showMenu(){
        if( 1 != this.context.rid ){
            return (
                <td style={!Util.authorityCheck("role") ? {display: 'none'} :{}}>
                    <a className="limit_duty_edit_i" href={"#/editrole/"+this.context.rid+"/"+this.pageNum+"/"+this.pageSize} ></a>
                    <i className="limit_duty_delete_i" onClick={this.deletz.bind(this,this.context.rid)} />
                </td>
            )
        }
    }
    /*渲染页面*/
    render() {
        return (
            <tr>
                <td>{this.context.rid}</td>
                <td>{this.context.name}</td>
                <td>{this.context.count}</td>
                {
                    this.showMenu()
                }
            </tr>
        )
    }
}
